package myThreadPool;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class Demo {
    public static void main(String[] args) {
        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(
                3,//核心线程数量
                6,//最大线程数量
                60,//空闲线程最大存活时间
                TimeUnit.SECONDS,//时间单位
                new ArrayBlockingQueue<>(3),//任务队列
                Executors.defaultThreadFactory(),//创建线程工厂
                new ThreadPoolExecutor.AbortPolicy()//任务的拒绝策略
        );
        Runnable r = new Run();
        threadPoolExecutor.submit(r);
        threadPoolExecutor.submit(r);
        threadPoolExecutor.submit(r);
        threadPoolExecutor.submit(r);
        threadPoolExecutor.submit(r);
        threadPoolExecutor.submit(r);
        threadPoolExecutor.submit(r);
        threadPoolExecutor.submit(r);
        threadPoolExecutor.submit(r);


    }
}
